package com.adou.d13;

import java.util.*;

public class CollectionTest1 {
    public static void main(String[] args) {
        List<Student> s = new ArrayList<>();
        Student stu1 = new Student("蜘蛛精", 25, 169.5);
        Student stu2 = new Student("紫霞", 25, 169.5);
        Student stu3 = new Student("牛夫人", 25, 169.5);
        Student stu4 = new Student("蜘蛛精", 25, 169.5);
        s.add(stu1);
        s.add(stu2);
        s.add(stu3);
        s.add(stu4);

        Iterator<Student> iterator = s.iterator();
        while(iterator.hasNext()) {
            String name = iterator.next().getName();
            if(name.contains("牛")) {
                iterator.remove();// 不会出现并发修改异常
            }
        }
        System.out.println(s);

        // 增强for变量集合，没有办法解决bug
    }
}
